<template>
  <el-dialog :visible.sync="open" @close="close" title="选择处置记录" width="700px" append-to-body>
    <el-table :data="list" max-height="250" size="mini">
      <el-table-column prop="planName" label="处置预案"> </el-table-column>
      <el-table-column prop="responseLevel" label="响应级别" width="120px" align="center">
        <template slot-scope="scope">
          {{ computeResponseLevel(scope.row.responseLevel) }}
        </template>
      </el-table-column>
      <el-table-column prop="responseLevel" label="总结状态" v-if="type == 'report'" width="120px" align="center">
        <template slot-scope="scope">
          {{ scope.row.reportStatus == 0 ? "待总结" : "已生成报告" }}
        </template>
      </el-table-column>
      <el-table-column label="操作" width="120px" align="center">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="handlePlayBack(scope.row)" v-if="type == 'playback'"> 过程回看 </el-button>
          <el-button type="text" size="small" @click="handleReport(scope.row)" v-if="type == 'report' && scope.row.reportStatus == 0"> 处置总结 </el-button>
        </template>
      </el-table-column>
    </el-table>
  </el-dialog>
</template>
<script>
import dialogMixin from "@/mixins/dialogMixin";
import { getHandleListByHandleInfoId } from "@/api/response/handle.js";

export default {
  name: "HandlePickerDialog",
  mixins: [dialogMixin],
  components: {},
  props: {
    type: {
      type: String,
      default: "playback",
    },
  },
  data() {
    return {
      title: "任务反馈附件",
      list: [],
      handleInfoId: 0,
      responseLevelOption: [
        {
          label: "Ⅰ级响应",
          value: 1,
        },
        {
          label: "Ⅱ级响应",
          value: 2,
        },
        {
          label: "Ⅲ级响应",
          value: 3,
        },
        {
          label: "Ⅳ级响应",
          value: 4,
        },
      ],
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    showDialog(handleInfoId) {
      this.handleInfoId = handleInfoId;
      this.getList();
      this.open = true;
    },
    getList() {
      getHandleListByHandleInfoId(this.handleInfoId).then(res => {
        if (res.data != null) {
          this.list = res.data;
        }
      });
    },
    computeResponseLevel(level) {
      let levelInfo = this.responseLevelOption.find(val => val.value == parseInt(level));
      return levelInfo.label;
    },
    handlePlayBack(data) {
      this.$emit("onSelected", data.handleId);
      this.open = false;
    },
    handleReport(data) {
      this.$emit("onSelected", data.handleId);
      this.open = false;
    },
  },
};
</script>
<style></style>
